package com.yys.gulimall.third.component;/*
 * @author zq
 */

import org.springframework.stereotype.Component;

/**
 * 使用阿里云短信服务 发送短信验证码
 */
@Component
public class SmsComponent {

    public void sendSmSCode(String phone,String code) {
        //先模拟发送
        mySendSms(phone,code);
    }

    public void mySendSms(String phone,String code) {
        System.out.println("短信验证码发送成功: " + code);
    }

    public void aliSendSms(String phone,String code) {

//        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
//        IAcsClient client = new DefaultAcsClient(profile);
//
//        CommonRequest request = new CommonRequest();
//        request.setSysMethod(MethodType.POST);
//        request.setSysDomain("dysmsapi.aliyuncs.com");
//        request.setSysVersion("2017-05-25");
//        request.setSysAction("SendSms");
//        request.putQueryParameter("RegionId", "cn-hangzhou");
//        request.putQueryParameter("PhoneNumbers", "13313017546");
//        try {
//            CommonResponse response = client.getCommonResponse(request);
//            System.out.println(response.getData());
//        } catch (ServerException e) {
//            e.printStackTrace();
//        } catch (ClientException e) {
//            e.printStackTrace();
//        }
    }
}
